//
//  RegisterNowFromView.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/15.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "RegisterNowFromView.h"

@implementation RegisterNowFromView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self.backImage addSubview:self.userNum];
        [self.backImage addSubview:self.userPassWord];
        [self.backImage addSubview:self.verification];
        [self.backImage addSubview:self.loginNow];
        [self.backImage addSubview:self.registerBtn];
        [self.verification addSubview:self.sendVerification];
        [self addSubview:self.backImage];
        
//        self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"zhucebg@3x"]];
        [self showRegister];
    }
    return self;
}

- (void)showRegister
{
    _backImage.sd_layout
    .topSpaceToView(self,0)
    .leftSpaceToView(self,0)
    .rightSpaceToView(self,0)
    .bottomSpaceToView(self,0);
    
    _userNum.sd_layout
    .topSpaceToView(self.backImage,kHeightScale(322))
    .leftSpaceToView(self.backImage,kWidthScale(62))
    .rightSpaceToView(self.backImage,kWidthScale(62))
    .heightIs(kHeightScale(44));
    
    _userPassWord.sd_layout
    .topSpaceToView(self.userNum,kHeightScale(15))
    .leftEqualToView(self.userNum)
    .rightEqualToView(self.userNum)
    .heightIs(kHeightScale(44));
    
    _verification.sd_layout
    .topSpaceToView(self.userPassWord,kHeightScale(15))
    .leftEqualToView(self.userNum)
    .rightEqualToView(self.userNum)
    .heightIs(kHeightScale(44));
    
    _sendVerification.sd_layout
    .topSpaceToView(self.verification,kHeightScale(16))
    .rightSpaceToView(self.verification,kWidthScale(10))
    .widthIs(kWidthScale(100))
    .heightIs(kHeightScale(12));
    
    _loginNow.sd_layout
    .topSpaceToView(self.verification,kHeightScale(15))
    .leftSpaceToView(self.backImage,kWidthScale(159))
    .widthIs(kWidthScale(60))
    .heightIs(kHeightScale(11));
    
    _registerBtn.sd_layout
    .topSpaceToView(self.loginNow,kHeightScale(21))
    .leftSpaceToView(self.backImage,kWidthScale(85))
    .rightSpaceToView(self.backImage,kWidthScale(85))
    .heightIs(kHeightScale(36));
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

// 账号
- (KQTextField *)userNum
{
    if (!_userNum)
    {
        _userNum = [[KQTextField alloc] init];
        _userNum.layer.borderWidth = 1;
        _userNum.layer.borderColor = [UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1].CGColor;
        _userNum.tag = 200000;
        _userNum.layer.cornerRadius = kWidthScale(6);
        _userNum.layer.masksToBounds = YES;
        _userNum.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shoujihao"]];
        _userNum.clearButtonMode = UITextFieldViewModeWhileEditing;
        _userNum.leftView.contentMode = UIViewContentModeScaleAspectFit; // 左视图图片自适应
        _userNum.leftViewMode = UITextFieldViewModeAlways; // 左视图图片一直显示
        _userNum.placeholder = @"手机号";
        _userNum.keyboardType = UIKeyboardTypeNumberPad;
    }
    return _userNum;
}
// 密码
- (KQTextField *)userPassWord
{
    if (!_userPassWord)
    {
        _userPassWord = [[KQTextField alloc] init];
        _userPassWord.layer.borderWidth = 1;
        _userPassWord.layer.borderColor = [UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1].CGColor;
        _userPassWord.tag = 200001;
        _userPassWord.layer.cornerRadius = kWidthScale(6);
        _userPassWord.layer.masksToBounds = YES;
        _userPassWord.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mima"]];
        _userPassWord.clearButtonMode = UITextFieldViewModeWhileEditing;
        _userPassWord.leftView.contentMode = UIViewContentModeScaleAspectFit; // 左视图图片自适应
        _userPassWord.leftViewMode = UITextFieldViewModeAlways; // 左视图图片一直显示
        _userPassWord.placeholder = @"密码";
        _userPassWord.secureTextEntry = YES;
    }
    return _userPassWord;
}
// 验证码
- (KQTextField *)verification
{
    if (!_verification)
    {
        _verification = [[KQTextField alloc] init];
        _verification.layer.borderWidth = 1;
        _verification.layer.borderColor = [UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1].CGColor;
        _verification.tag = 200002;
        _verification.layer.cornerRadius = kWidthScale(6);
        _verification.layer.masksToBounds = YES;
        _verification.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yanzhengma"]];
        _verification.clearButtonMode = UITextFieldViewModeWhileEditing;
        _verification.leftView.contentMode = UIViewContentModeScaleAspectFit; // 左视图图片自适应
        _verification.leftViewMode = UITextFieldViewModeAlways; // 左视图图片一直显示
        _verification.placeholder = @"验证码";
//        _verification.secureTextEntry = YES;
        _verification.keyboardType = UIKeyboardTypeNumberPad;
    }
    return _verification;
}
// 立即登陆
- (UIButton *)loginNow
{
    if (!_loginNow)
    {
        _loginNow = [UIButton buttonWithType:UIButtonTypeCustom];
        [_loginNow setTitle:@"立即登陆" forState:0];
        [_loginNow setTitleColor:[UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1] forState:0];
        _loginNow.titleLabel.font = [UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _loginNow;
}
// 注册
- (UIButton *)registerBtn
{
    if (!_registerBtn)
    {
        _registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _registerBtn.layer.borderWidth = 1;
        _registerBtn.layer.borderColor = [UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1].CGColor;
        _registerBtn.layer.cornerRadius = kWidthScale(18);
        _registerBtn.layer.masksToBounds = YES;
        [_registerBtn setTitle:@"注册" forState:0];
        [_registerBtn setTitleColor:[UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1] forState:0];
        _registerBtn.titleLabel.font = [UIFont systemFontOfSize:kWidthScale(14)];
    }
    return _registerBtn;
}

- (UIButton *)sendVerification
{
    if (!_sendVerification)
    {
        _sendVerification = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sendVerification setTitle:@"获取验证码" forState:0];
        [_sendVerification setTitleColor:[UIColor colorWithRed:66.0/255.0 green:167.0/255.0 blue:235.0/255.0 alpha:1] forState:0];
        _sendVerification.titleLabel.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _sendVerification.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 1);
    }
    return _sendVerification;
}

- (UIImageView *)backImage
{
    if (!_backImage)
    {
        _backImage = [[UIImageView alloc] init];
        _backImage.image = [UIImage imageNamed:@"zhucebg"];
        _backImage.contentMode = UIViewContentModeScaleAspectFit;
        _backImage.userInteractionEnabled = YES;
    }
    return _backImage;
}

@end
